import {
	HTTP
} from './http.js';
//  const rootUrl = "https://test.gyzj.anlingxinxi.com/";
const rootUrl = "https://m.zxgyzj.com/";
// const rootUrl = "http://gyzj_frontend.com/";
class GYZJMODEL extends HTTP {
	constructor() {
		super();
	}
	/*-----------------------------------------接口请求类函数--------------------------------------------------------*/
	/*-----------------------------------------万人群模块的开始----------------------------------------*/
	//已开放城市
	getCity(token) {
		return this.request({
			url: 'room/city?token=${token}',
			method: 'GET'
		})
	}
	//聊天室列表
	getChatList(id) {
		return this.request({
			url: 'room/list/' + id,
			method: 'GET'
		})
	}
	//高级群列表 
	getSeniorList(cityId) {
		return this.request({
			url: 'group/list/' + cityId,
			method: 'GET',
		})
	};
	//聊天详情
	getChatMore(id) {
		return this.request({
			url: 'room/view/'+id,
			method: 'GET'
		})
	};
	//高级群详情
	getSeniorMore(id) {
		return this.request({
		  url: 'group/view/'+id,
			method: 'GET',
		})
	};
	//测试网易云接口
	getIm(token,type) {
		if(type==1){
			return this.request({
				url: 'app/test-server?token='+token,
				method: 'GET'
			})
		}else if(type==2){
			return this.request({
				url: 'app/test-server?mobile='+token,
				method: 'GET'
			})
		}
	};
	/*-----------------------------------------万人群模块的结束----------------------------------------*/
	//更新用户信息
	updataUserInfo(token, data, type) {
		if (type == 1) {
			return this.request({
				url: 'user/info?token=' + token,
				data,
				method: 'POST'
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/info?mobile=' + token,
				data,
				method: 'POST'
			})
		}
	};
	//获取用户信息 token或者手机号
	getUserInfo(token, type) {
		if (type == 1) {
			console.log('token用户信息');
			return this.request({
				url: 'user/info?token=' + token,
			})
		} else if (type == 2) {
			console.log('mobile用户信息');
			return this.request({
				url: 'user/info?mobile=' + token,
			})
		}
	};
	//根据注册手机号，获取个人信息
	getUserInfoMobile(data, type,clientid) {
		clientid=clientid||'';
		if (type == 1) {
			console.log('token用户信息');
			return this.request({
				url: 'user/mobile?clientid='+clientid,
				method: 'POST',
				data,
			})
		} else if (type == 2) {
			console.log('mobile用户信息');
			return this.request({
				url: 'user/mobile?clientid='+clientid,
				method: 'POST',
				data,
			})
		}
	};
	// 获取附近的工人
	getNearbyWorker(longitude, latitude, token, type, native_district_id, category_id, mobile) {
		if (mobile) {
			console.log('手机附近工人');
			return this.request({
				url: 'work/indextwo?longitude=' + longitude + '&latitude=' + latitude + '&mobile=' + mobile + '&type=' + type +
					'&native_district_id=' + native_district_id + '&category_id=' + category_id,
			})
		} else if (token) {
			console.log('token附近工人');
			return this.request({
				url: 'work/indextwo?longitude=' + longitude + '&latitude=' + latitude + '&token=' + token + '&type=' + type +
					'&native_district_id=' + native_district_id + '&category_id=' + category_id,
			})
		}
	}
	/*根据经纬度拿城市==（无用）*/
	getLongitudeCity(longitude, latitude) {
		return this.request({
			url: 'https://api.map.baidu.com/geocoder/v2/?ak=bH9q1U0VG3TDls0D6AQgeZmV95qXlNvW&location=' + longitude + ',' +
				latitude + '&output=json&pois=1',
		})
	}
	//获取首页工人列表
	getWorkerList(work_category_id, native_district_id, district_id) {
		return this.request({
			url: 'work/index?work_category_id=' + work_category_id + '&native_district_id=' + native_district_id +
				"&district_id=" + district_id,
		})
	}
	//获取工人详情
	getWorkerDetail(id) {
		return this.request({
			url: 'work/view/'+id,
		})
	}
	//环信获取工人详情
	getHxDetail(id) {
		return this.request({
			url: 'app/get-info/'+id,
		})
	}
	//获取带jobId的工人详情
	getJobWorkerDetail(id,jobId) {
		return this.request({
			url: 'work/view/'+id+'?jobId='+jobId,
		})
	}
	//获取两坐标直线的距离
	getDistance(lng1, lat1, lng2, lat2) {
		return this.request({
			url: 'common/distance?lng1=' + lng1 + '&lat1=' + lat1 + '&lng2=' + lng2 + '&lat2=' + lat2,
		})
	}
	/*授权获取手机号码*/
	decryptPhone(data) {
		return this.request({
			url: 'wechat/decrypt',
			data,
			method: 'POST'
		})
	}
	/*施工队*/
	getMySubordinate(ctype, token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/subordinate?type=' + ctype + '&token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/subordinate?type=' + ctype + '&mobile=' + token,
			})
		}
	}
	/*短信发送接口=====这里写重了*/
	sendCode(data) {
		return this.request({
			url: 'common/mobile-captcha',
			data,
			method: 'POST',
		})
	}
	/*获取手机号码*/
	getCaptcha(data) {
		return this.request({
			url: 'common/mobile-captcha',
			data,
			method: 'POST'
		})
	}
	/*验证修改手机号码 */
	updateMobile(data, token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/mobile?token=' + token,
				data,
				method: 'POST',
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/mobile?mobile=' + token,
				data,
				method: 'POST',
			})
		}
	}
	// 获取商户列表
	getMerchantsList(token, type) {
		if (type == 1) {
			return this.request({
				url: 'merchant/list?token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/list?mobile=' + token,
			})
		}
	}
	//商户详情
	getMerchantsDetailed(id) {
		return this.request({
			url: 'merchant/view/' + id,
		})
	};
	/*详情（招募合伙人等）*/
	getNewsDetail(postData) {
		return this.request({
			url: 'article/' + postData
		})
	}
	/*列表（使用指南等)*/
	getNewsList(cat, page) {
		page = page || 1;
		return this.request({
			url: 'article/category/' + cat + '?page=' + page
		})
	}
	// 查看会员等级列表
	getVipLevel() {
		return this.request({
			url: 'viplever',
		})
	}
	//获取所有工种列表
	getWorkerCategory() {
		return this.request({
			url: 'work/category',
		})
	}
	/*获取地区*/
	getReginList(id) {
		return this.request({
			url: 'common/region/' + id,
		})
	}
	/*收藏商家列表*/
	collectMerchantList(token, type) {
		if (type == 1) {
			return this.request({
				url: 'merchant/favorites-list?token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/favorites-list?mobile=' + token,
			})
		}
	}
	// 收藏名片列表
	collectCardList(token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/favorites-list?token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/favorites-list?mobile=' + token,
			})
		}
	}
	//跳商家二维码
	merchantEwmCode(id, url) {
		return this.request({
			url: 'user/merchant-code-type/' + id,
		})
	};
	//跳首页二维码
	indexEwmCode(id, url) {
		return this.request({
			url: 'user/index-code-type/' + id,
		})
	};
	//跳名片二维码
	infoEwmCode(id) {
		return this.request({
			url: 'user/card-code-type/' + id,
		})
	};
	/*微信支付-查询订单支付情况*/
	checkWechatOrder(orderNum) {
		return this.request({
			url: 'wechat/query/' + orderNum,
		})
	}
	/*微信支付-充值*/
	recharge(token, type, data) {
		if (type == 1) {
			return this.request({
				url: 'deposit?token=' + token,
				data,
				method: 'POST',
			})
		} else if (type == 2) {
			return this.request({
				url: 'deposit?mobile=' + token,
				data,
				method: 'POST',
			})
		}
	}
	// 获取公共参数 admission_money会员入驻费用,admission_month会员入驻有效期(月),withdraw_rate提现手续费费率(%),integrity_amount诚信金数额
	getCommonParms(parms) {
		return this.request({
			url: 'common/params?code=' + parms,
		})
	}
	/*转出*/
	withdraw(token, type, data) {
		if (type == 1) {
			return this.request({
				url: 'user/withdraw?token=' + token,
				data,
				method: 'POST',
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/withdraw?mobile=' + token,
				data,
				method: 'POST',
			})
		}
	}
	/*余额记录*/
	getMoneyRecord(page, token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/money-log?page=' + page + '&token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/money-log?page=' + page + '&mobile=' + token,
			})
		}
	}
	// 获取商户分类
	getMerchantsClass() {
		return this.request({
			url: 'merchant/category',
		})
	};
	//获取订单列表
	getOrderRecord(loginType, type, userType, page, token, loadMore,is_business) {
		loadMore=false;
		type = type || 0;
		userType = userType || 0;
		page = page || 1;
		console.log('过来的is_business',is_business);
		is_business = is_business || 1;

		if (loginType == 1) {
			return this.request({
				url: 'work/order-list?type=' + type + '&user_type=' + userType + '&page=' + page + '&token=' + token +
					'&is_business=' + is_business,
			})
		} else if (loginType == 2) {
			console.log('订单列表的is_business',is_business);
			return this.request({
				url: 'work/order-list?type=' + type + '&user_type=' + userType + '&page=' + page + '&mobile=' + token +
					'&is_business=' + is_business,
			})
		}
	}
	/*获取省份/城市订单列表*/
	getOrderList(postData) {
		return this.request({
			url: 'work-order/city-order/' + postData.id + '?type=' + postData.type,
		})
	}
	/*我联系过的*/
	getContactedList(token, type) {
		if (type == 1) {
			return this.request({
				url: 'work-order/my-log?token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'work-order/my-log?mobile=' + token,
			})
		}
	}
	/*获取新订单详情*/
	getfreshOrderDetail(id) {
		return this.request({
			url: 'work/testorderview?id=' + id,
		})
	}
	/*订单详情拨打电话进行扣款 type为1为微信登录，type为2为手机登录*/
	postOrderWithMoney(token, type,postData) {
		if (type == 1) {
			return this.request({
				url: 'work-order/go?token=' + token,
				method: "POST",
				data:postData,
			})
		} else if (type == 2) {
			return this.request({
				url: 'work-order/go?mobile=' + token,
				method: "POST",
				data:postData,
			})
		}
	}
	// 自定义上传个人资料照片
	uploadDiyPhoto(formData, filePaths, name, i, token, type,userInfo,files) {
		if (type == 1) {
			console.log('执行自定义图片上传1');
			console.log('执行自定义图片上传2');
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'user/info?token=' + token,
					filePath: filePaths[i],
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					formData: formData,
					success: function(res) {
						console.log('上传成功的执行');
						resolve(res.data);
					},
					fail: function(error) {
						console.log('上传失败的执行');
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						console.log('递归的执行');
						console.log('i的值为',i);
						console.log('filePaths.length的值为',filePaths.length);
						reject();
					}
				});
			});
		} else if (type == 2) {
			console.log('执行自定义图片上传2');
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'user/info?mobile=' + token,
					filePath: filePaths[i],
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					formData: formData,
					success: function(res) {
						console.log('上传成功的执行');
						resolve(res.data);
					},
					fail: function(error) {
						console.log('上传失败的执行');
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						console.log('递归的执行');
						console.log('i的值为',i);
						console.log('filePaths.length的值为',filePaths.length);
						// i++;
						// if(i==filePaths.length){
						// 	console.log('不执行操作');
						// 	// GYZJMODEL.prototype.getUserInfo(token,type).then(data => {
						// 	// 	this.userInfo=data.data.user;
						// 	// 	this.files=data.data.user.poster;
						// 	// });
						// }else{
						// 	console.log('继续上传图片');
						// 	GYZJMODEL.prototype.uploadDiyPhoto(formData,filePaths,name,i,token,type);
						// }
						reject();
					}
				});
			});
		}
	}
	//删除图片
	deletePhoto(data, token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/delete-picture?token=' + token,
				method: "POST",
				data,
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/delete-picture?mobile=' + token,
				method: "POST",
				data,
			})
		}
	}
	//更换头像
	updateAvatar(token, type, filePath, name) {
		if (type == 1) {
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'user/avatar?token=' + token,
					filePath: filePath,
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		} else if (type == 2) {
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'user/avatar?mobile=' + token,
					filePath: filePath,
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		}
	}
	
	//更换头像
	updateAvatarGroups(token, type, filePath, name) {
		if (type == 1) {
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'app-im/avatar?token=' + token,
					filePath: filePath,
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		} else if (type == 2) {
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'app-im/avatar?mobile=' + token,
					filePath: filePath,
					name: name,
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		}
	}
	//购买会员的接口
	buyVip(data, token, type, levelId) {
		if (type == 1) {
			return this.request({
				url: 'viporder?token=' + token,
				method: 'POST',
				data,
			})
		} else if (type == 2) {
			return this.request({
				url: 'viporder?mobile=' + token,
				method: 'POST',
				data,
			})
		}
	}
	// 查询微信支付结果
	checkWechatOrder(order) {
		return this.request({
			url: 'wechat/query/' + order
		})
	}
	// 团购报名、兼职业务员列表
	registrationList(id, type) {
		return this.request({
			url: 'merchant/signup-list/' + id + '?type=' + type,
		})
	}
	/*-------------------------------我的店铺*/
	myMerchants(token, type) {
		if (type == 1) {
			return this.request({
				url: 'merchant/my?token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/my?mobile=' + token,
			})
		}
	}
	// 获取保存商户信息 (参数不全)
	getSaveMerchants(token, type, data) {
		if (type == 1) {
			return this.request({
				url: 'merchant/create?token=' + token,
				method: 'POST',
				data
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/create?mobile=' + token,
				method: 'POST',
				data
			})
		}
	};
	//发布商家
	issueMerchants(data, token, type) {
		if (type == 1) {
			return this.request({
				url: 'merchant/publish?token=' + token,
				method: 'POST',
				data
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/publish?mobile=' + token,
				method: 'POST',
				data
			})
		}
	};
	// 上传店铺照片  (接口写重来，前端写的，参数全一些)
	uploadStorePhoto(formData, filePaths, name, i, token, type, loginType) {

		if (loginType == 1) {
			return this.request({
				url: 'merchant/create?token=' + token,
				method: 'POST',
				name: name,
				header: {
					"Content-Type": "multipart/form-data"
				},
				formData: formData,
				filePath: filePaths[i],
			})
		} else if (loginType == 2) {
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'merchant/create?mobile=' + token,
					method: 'POST',
					name,
					filePath: filePaths[i],
					header: {
						"Content-Type": "multipart/form-data"
					},
					formData: formData,
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(complete) {
						// callBackComplete(complete);
						// console.log('递归方法');
						// //不管成功还是失败都会执行
						reject();
					}
				});
			});

			// return this.request({
			// 	url: 'merchant/create?mobile=' + token,
			// 	method: 'POST',
			// 	name: name,
			// 	header: {
			// 		"Content-Type": "multipart/form-data"
			// 	},
			// 	formData: formData,
			// 	filePath: filePaths[i],
			// })
		}
	};
	// 收藏用户接口
	collectCard(id, token, type) {
		if (type == 1) {
			return this.request({
				url: 'user/user-favorites?id=' + id + '&token=' + token,
			})
		} else if (type == 2) {
			return this.request({
				url: 'user/user-favorites?id=' + id + '&mobile=' + token,
			})
		}
	};
	/*刪除圖片*/
	merchantDeletePhoto(postData, token, type) {
		if (type == 1) {
			return this.request({
				url: 'merchant/delete-picture?token=' + token + '&name=' + postData.name + '&picture=' + postData.picture,
			})
		} else if (type == 2) {
			return this.request({
				url: 'merchant/delete-picture?mobile=' + token + '&name=' + postData.name + '&picture=' + postData.picture,
			})
		}
	}
	//调用发单的接口
	orderRelease(token, postData, type) {
		if (type == 1) {
			return this.request({
				url: 'work/order?token=' + token,
				method: 'POST',
				header: {
					"Content-Type": "application/json"
				},
				data: postData,
			})
		} else if (type == 2) {
			return this.request({
				url: 'work/order?mobile=' + token,
				method: 'POST',
				header: {
					"Content-Type": "application/json"
				},
				data: postData,
			})
		}
	}
	/*获取二手闲置的列表*/
	getJobWantList(type, token, time, district_id, loginType) {
		type = type || 1;
		time = time || 0;
		district_id = district_id || 0;
		if (loginType == 1) {
			return this.request({
				url: 'job-want/list?type=' + type + '&token=' + token + '&time=' + time + '&district_id=' + district_id,
				method: 'GET',
				header: {
					"Content-Type": "application/json"
				},
			})
		} else if (loginType == 2) {
			return this.request({
				url: 'job-want/list?type=' + type + '&mobile=' + token + '&time=' + time + '&district_id=' + district_id,
				method: 'GET',
				header: {
					"Content-Type": "application/json"
				},
			})
		}
	}
	/*获取二手闲置的详情*/
	getJobWantView(id) {
		return this.request({
			url: 'job-want/view/' + id,
			method: 'GET',
			header: {
				"Content-Type": "application/json"
			},
		})
	}
	/*发布找工人(附近的工人)*/
	getnearbyList(token,type){
		if(type==1){
			return this.request({
				url: 'work-order/nearby?token=' + token,
				method: 'GET',
				header: {
					"Content-Type": "application/json"
				},
			})
		}else if(type==2){
			return this.request({
				url: 'work-order/nearby?mobile=' + token,
				method: 'GET',
				header: {
					"Content-Type": "application/json"
				},
			})
		}
	}
	//上传业主装修报名
	orderRenoJob(token,type,postData){
		if(type==1){
			return this.request({
				url: 'job-want/create-reno?token=' + token,
				method: 'POST',
				header: {
					"Content-Type": "application/json"
				},
				data: postData,
			})
		}else if(type==2){
			return this.request({
				url: 'job-want/create-reno?mobile=' + token,
				method: 'POST',
				header: {
					"Content-Type": "application/json"
				},
				data: postData,
			})
		}
	}
	/*发布二手闲置和找活信息接口*/
	orderReleaseJob(token,type,postData){
		if(type==1){
			return this.request({
				url: 'job-want/create-job?token=' + token,
				method: 'POST',
				data: postData,
			})
		}else if(type==2){
			return this.request({
				url: 'job-want/create-job?mobile=' + token,
				method: 'POST',
				data: postData,
			})
		}
	}
	/*发布订单现场图片的处理*/
	uploadScenePhoto(orderId,i,files,token,type){
		if(type==1){
			
		}else if(type==2){
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'work/picture?mobile=' + token,
					filePath: files[i],
					name: 'poster',
					formData: {
					  "work_order_id": orderId,
					},
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		}
	}
	/*发布二手闲置和找工作的图片处理*/
	uploadJobScenePhoto(jobId,i,files,token,type){
		if(type==1){
			
		}else if(type==2){
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'job-want/job-picture?mobile=' + token,
					filePath: files[i],
					name: 'poster',
					formData: {
					  "job_id": jobId,
					},
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		}
	}
	/*发布二手闲置和找工作的图片处理*/
	uploadJobfmScenePhoto(jobId,i,files,token,type){
		if(type==1){
			
		}else if(type==2){
			return new Promise((resolve, reject) => {
				uni.uploadFile({
					url: rootUrl + 'job-want/jobfm-picture?mobile=' + token,
					filePath: files[i],
					name: 'poster_img',
					formData: {
					  "job_id": jobId,
					},
					header: {
						"Content-Type": "multipart/form-data"
					},
					success: function(res) {
						resolve(res.data);
					},
					fail: function(error) {
						reject();
						console.log('error', error);
						HTTP.prototype._show_error(res.data.message);
					},
					complete: function(error) {
						//不管成功还是失败都会执行
						reject();
					}
				});
			});
		}
	}
	// 获取施工队诚信金
	getContractorMoney(){
			return this.request({
				url: 'work/contractor-money',
			})
	
	}
	//获取附近工人列表
	getnearbyWorkList(postData,token,type){
		if(type==1){
			return this.request({
				url: 'work-order/nearby?work_category_id='+postData.category_id+'&ctiy_id'+postData.ctiy_id+'&token='+token,
				method: 'GET',
			})
		}else if(type==2){
			return this.request({
				url: 'work-order/nearby?work_category_id='+postData.category_id+'&ctiy_id'+postData.ctiy_id+'&mobile='+token,
				method: 'GET',
			})
		}
	}
	//拨打附近的人的电话 （每天免费5次)
	callWorker(postData,token,type){
		if(type==1){
			return this.request({
				url: 'user/call?token='+token,
				method: 'POST',
				data: postData,
			})
		}else if(type==2){
			return this.request({
				url: 'user/call?mobile='+token,
				method: 'POST',
				data: postData,
			})
		}
	}
	/*入驻的操作*/
	switchIdentity(token,type,postData){
		if(type==1){
			return this.request({
				url: 'user/admission?token='+token,
				method: 'POST',
				data: postData,
			})
		}else if(type==2){
			return this.request({
				url: 'user/admission?mobile='+token,
				method: 'POST',
				data: postData,
			})
		}
	}
	/*發單找商家*/
	merchantOrderRelease(token,type,postData){
		if(type==1){
			return this.request({
				url: 'work/order-business?token='+token,
				method: 'POST',
				data: postData,
			})
		}else if(type==2){
			return this.request({
				url: 'work/order-business?mobile='+token,
				method: 'POST',
				data: postData,
			})
		}
	}
	/*用户默认登录接口*/
	userLogin(postData){
		return this.request({
			url: 'user/login',
			method: 'POST',
			header: {
			  "Content-Type": "application/x-www-form-urlencoded"
			},
			data: postData,
		})
	}
	/*APP的用户微信登录接口*/
	AppUserLogin(postData,clientid){
		clientid=clientid||'';
		return this.request({
			url: 'user/app-login?clientid='+clientid,
			method: 'POST',
			header: {
			  "Content-Type": "application/x-www-form-urlencoded"
			},
			data: postData,
		})
	}
	/*用户收藏接口*/
	 // 收藏商家接口
	  collectMerchant(id, token,type) {
		  if(type==1){
			  return this.request({
			    url: 'merchant/merchant-favorites?id='+id+'&token=' + token,
			  })
		  }else if(type==2){
			  return this.request({
			    url: 'merchant/merchant-favorites?id='+id+'&mobile=' + token,
			  })
		  }
	  };
	  /*消息推送的接口(针对所有用户)*/
	    messagePushAll(data) {
		  return this.request({
		  	url: 'app/message-push',
		  	data,
		  	method: 'POST'
		  })
	    };
		/*环信的获取所有群的信息,这个已废弃*/
		chatGroupsAll() {
		  return this.request({
		  	url: 'app-im/chat-groups',
		  	method: 'GET'
		  })
		};
		/*得到所有群的类型*/
		groupsNameAll() {
		  return this.request({
		  	url: 'app-im/groups-name',
		  	method: 'GET'
		  })
		};
		/*得到所有省*/
		getRegionParent() {
		  return this.request({
		  	url: 'app-im/get-region',
		  	method: 'GET'
		  })
		};
		/*得到筛选的群组*/
		getGroupsShai(group_id,province_id){
			console.log('group_id的值',group_id);
			console.log('province_id的值',province_id);
			group_id=group_id||0;
			province_id=province_id||0;
			return this.request({
				url: 'app-im/groups-shai?group_id='+group_id+'&province_id='+province_id,
				method: 'GET'
			}) 
		}
		/*得到筛选的群组*/
		listGroupsAllShare(token, type){
			if (type == 1) {
				return this.request({
					url: 'app-im-share/group-list?token='+token,
					method: 'GET'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im-share/group-list?mobile='+token,
					method: 'GET'
				})
			}
		}
		/*得到群的详情*/
		getGroupUpdateNum(id,person_num){
			return this.request({
				url: 'app-im/update-num?id='+id+'&person_num='+person_num,
				method: 'GET'
			})
		}
		/*根据环信群id得到群的id和人数*/
		getGroupGetid(id){
			return this.request({
				url: 'app-im/group-getid?id='+id,
				method: 'GET'
			})
		}
		/*得到群的详情*/
		getSettingAllavatar(id,data){
			return this.request({
				url: 'app-im/setting-allavatar?id='+id,
				method: 'POST',
				data
			})
		}
		/*得到自己创建的群组*/
		getMyGroups(token,type){
			if (type == 1) {
				return this.request({
					url: 'app-im/my-create?token='+token,
					method: 'GET'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im/my-create?mobile='+token,
					method: 'GET'
				})
			}
		}
		/*创建自己的群操作*/
		PostCreateGroups(token,type,data){
			if (type == 1) {
				return this.request({
					url: 'app-im/create-group?token='+token,
					data,
					method: 'POST'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im/create-group?mobile='+token,
					data,
					method: 'POST'
				})
			}
		}
		/*创建自己的群操作*/
		PostEditGroups(token,type,data,id){
			if (type == 1) {
				return this.request({
					url: 'app-im/edit-group?token='+token+'&id='+id,
					data,
					method: 'POST'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im/edit-group?mobile='+token+'&id='+id,
					data,
					method: 'POST'
				})
			}
		}
		/*创建自己的群操作*/
		groupsSendMsg(token,type,data){
			if (type == 1) {
				return this.request({
					url: 'app-im/send-msg?token='+token,
					data,
					method: 'POST'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im/send-msg?mobile='+token,
					data,
					method: 'POST'
				})
			}
		}
		/*待结算群分红记录*/
		getCommissionInfoHas(token,type,is_send=0){
			if (type == 1) {
				return this.request({
					url: 'app-im-share/commission-has?token='+token+"&is_send="+is_send,
					method: 'GET'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im-share/commission-has?mobile='+token+"&is_send="+is_send,
					method: 'GET'
				})
			}
		}
		/*待结算群分红记录*/
		getInviteUser(token,type,group_id=0,share_uid=0,id=0){
			if (type == 1) {
				return this.request({
					url: 'app-im-share/invite-user?token='+token+"&group_id="+group_id+'&share_uid='+share_uid+'&id='+id+'&is_pay=1',
					method: 'GET'
				})
			} else if (type == 2) {
				return this.request({
					url: 'app-im-share/invite-user?mobile='+token+"&group_id="+group_id+'&share_uid='+share_uid+'&id='+id+'&is_pay=1',
					method: 'GET'
				})
			}
		}
		/*一个手机号的操作*/
		PostOneMobile(data){
			return this.request({
				url: 'app/one-mobile',
				method: 'POST',
				data,
			})
		}
		//上传业主装修报名
		orderRenoJob(data, token, type) {
			if (type == 1) {
				return this.request({
					url: 'job-want/create-reno?token=' + token,
					method: "POST",
					data,
				})
			} else if (type == 2) {
				return this.request({
					url: 'job-want/create-reno?mobile=' + token,
					method: "POST",
					data,
				})
			}
		}
	/*-----------------------------------------自定义通用类功能函数--------------------------------------------------------*/
	/*分享单人链接的函数*/
	shareLink(title,imageUrl,wx_id,path){
		uni.share({
		    provider: "weixin",
		    scene: "WXSceneSession",
			// imageUrl:'https://img-cdn-qiniu.dcloud.net.cn/uniapp/app/share-logo@3.png',
			imageUrl:imageUrl,
			title:title,
		    type: 5,
			summary: title, 
			miniProgram:{
				id:wx_id,
				path:path,
				type:0,
				webUrl:'http://uniapp.dcloud.io'
			},
		    success: function (res) {
				/*返回app会执行的方法*/
		        console.log("success:" + JSON.stringify(res));
		    },
		    fail: function (err) {
		        console.log("fail:" + JSON.stringify(err));
		    }
		});
	}
	goImageLoad(e){
		var $width = e.detail.width,    //获取图片真实宽度
		  $height = e.detail.height,
		  ratio = $width / $height;
		var viewWidth = 718,           //设置图片显示宽度，左右留有16rpx边距
		  viewHeight = 718 / ratio;
		var image = this.images;
		//将图片的datadata-index作为image对象的key,然后存储图片的宽高值
		image[e.target.dataset.index] = {
		  width: viewWidth,
		  height: viewHeight
		}
		return image;
	}
	/*统一登录的代码,这里不能进行封装*/
	goModelLogin(){
		let arr=main_getGlobal();
		main_is_login(arr);
		if(arr.token=='0739'){
			return false;
		}
	}
	showUserModal(path){
		uni.showModal({
		   title: '您还未入驻',
		   content: '您暂时不能发单、接单或创建队伍，点击【确认】马上去入驻。',
		   confirmColor: '#F94C48',
		   success: function (res) {
		     if (res.confirm) {
		       uni.navigateTo({
		         url: path,
		       })
		     } else if (res.cancel) {
		       console.log('用户点击取消')
		     }
		   }
		 })
	}
	/*温馨提示完善信息*/
	identityInformation(path){
		 uni.showModal({
		    title: '温馨提示',
		    content: '为方便客户更全面的了解您，让您接到更多的业务，请完善您的个人资料。',
		    confirmColor: '#F94C48',
		    success: function (res) {
		      if (res.confirm) {
		        uni.navigateTo({
		          url: path,
		        })
		      } else if (res.cancel) {
		        console.log('用户点击取消')
		      }
		    }
		  })
	}
	/*设置全局播放音乐*/
	musicPlay(url) {
	    let backgroundAudioManager = uni.getBackgroundAudioManager();
	    backgroundAudioManager.title = '同城共享装修';
	    backgroundAudioManager.epname = '同城共享装修';
	    backgroundAudioManager.singer = '同城共享装修';
	    backgroundAudioManager.src = url;
	  }
	/*设置关闭音乐*/
	musicPause() {
	  const music = uni.getBackgroundAudioManager();
	  // stop();
	  return music.pause();
	}
	// 返回已填写的表单数据
	getFilledData(formData) {
		let obj = {};
		for (let i in formData) {
			if (formData[i]) {
				obj[i] = formData[i];
			}
		};
		return obj;
	}
	//一个on作(订阅) 暂时好像没用
	// function on(name, self, callback) {
	//   var tuple = [self, callback];
	//   var callbacks = events[name];
	//   if (Array.isArray(callbacks)) {
	//     callbacks.push(tuple);
	//   }
	//   else {
	//     events[name] = [tuple];
	//   }
	// }
	// 根据工种id获取工种的图像地址
	getWorkerTypeImg(id) {
		if (id) {
			return "/static/images/worker-type/wk_" + id + ".png";
		}
		return "/static/images/worker-type/wk_default.png";
	}
	// 星星评分组件实现
	convertToStarsArray(stars, num = 5) {
		let array = [];
		for (let i = 1; i <= num; i++) {
			if (i <= stars) {
				array.push(1);
			} else {
				array.push(0);
			}
		}
		return array;
	}
	//执行错误详情传参 (此处重复，借用了http.js的函数)
	// _show_error(msg='出现了一个错误'){
	// 	console.log('错误的执行');
	// 	uni.hideLoading();
	// 	uni.showModal({
	// 		content: msg,
	// 		showCancel: false
	// 	})
	// }
	// 自定义错误请求消息提示
	errorMessage(data) {
		if (data['status'] == 412) {
			if (typeof(data['responseJSON']['message'] === 'string')) {
				uni.showToast({
					title: data['responseJSON']['message']
				})
			} else if (typeof(data['responseJSON']['message'] === "object")) {
				if (Array.isArray(data['responseJSON']['message'])) {
					var oArray = [];
					for (var item in data['responseJSON']['message'][0]) {
						oArray.push(data['responseJSON']['message'][0][item]);
					}
					uni.showToast({
						title: oArray[0].toString()
					});
				} else {
					var oArray = [];
					for (var item in data['responseJSON']['message']) {
						oArray.push(data['responseJSON']['message'][item]);
					}
					uni.showToast({
						title: oArray[0].toString()
					});
				}
			} else if (data['status'] == 401) {

			} else {
				if (data['responseJSON']) {
					uni.showToast({
						title: data['responseJSON']['message']
					});
				} else {
					uni.showToast({
						title: '请求错误,请重试'
					});
				}
			}
		}
	}
	// 日期格式化 type为1返回年月日时分秒，type为2返回年月日,type为3返回年月日时分
	formatTime(time, type) {
		type = type || 1;
		var datetime = new Date();
		datetime.setTime(time * 1000);
		const year = datetime.getFullYear();
		const month = datetime.getMonth() + 1;
		const day = datetime.getDate();
		const hour = datetime.getHours();
		const minute = datetime.getMinutes();
		const second = datetime.getSeconds();
		if (type === 1) {
			return [year, month, day].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join('-') + ' ' + [hour, minute, second].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join(':');
		} else if (type === 2) {
			console.log('type为2的执行', [year, month, day]);
			console.log([year, month, day].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join('-'));
			return [year, month, day].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join('-');
		} else if (type === 3) {
			return [year, month, day].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join('-') + ' ' + [hour, minute].map(n => {
				n = n.toString();
				return n[1] ? n : '0' + n
			}).join(':');
		}
	}
	formatNumber(n) {
		console.log('n的值', n);
		n = n.toString();
		return n[1] ? n : '0' + n;
	}
	saveFormIdF = function(postData, token) {
		saveFormId((data) => {
			switch (data.code) {
				case 1:
					console.log('上传formid成功a');
					break;
				default:
					console.log('上传formid失败a');
					uni.showToast({
						title: data.message,
						icon: 'none'
					});
					break;
			}
		}, (error) => {
			uni.hideLoading();
		}, postData, token)
	}
	/*提示消息类*/
	showMsg() {
		uni.showModal({
			title: '提交失败',
			content: '请填写完带【图标】的"必填信息"后，再进行提交。',
			showCancel: false,
			confirmColor: '#f94c48',
		})
	}
	// 检测对象是否有值
	isObjValid(obj) {
		for (let i in obj) {
			if (!obj[i]) return false;
		}
		return true;
	}
	/*生成富文本节点*/
	generateRichTextNode(text) {
	  let tempStr = text
	  let richTextNode = []
	  let leftBracketIndex = tempStr.indexOf('[')
	  let rightBracketIndex = tempStr.indexOf(']')
	  let countOfWord = 0
	  Array.from(tempStr).map(item => {
	    if (item != '[' && item != ']') {
	      countOfWord++
	    }
	  })
	  if (leftBracketIndex == -1 || rightBracketIndex == -1 || countOfWord == 0) {//没有emoji
	    richTextNode.push({
	      type: 'text',
	      text: tempStr
	    })
	    return richTextNode
	  }
	  while (tempStr.length != 0) {
	    leftBracketIndex = tempStr.indexOf('[')
	    rightBracketIndex = tempStr.indexOf(']')
	    if (leftBracketIndex == 0) { // 开头是[
	      rightBracketIndex = tempStr.indexOf(']')
	      if (rightBracketIndex == -1) {
	        richTextNode.push({
	          type: 'text',
	          text: tempStr
	        })
	        tempStr = ''
	      } else {
	        let emojiName = tempStr.slice(0, rightBracketIndex + 1)
	        if (emoji[emojiName]) { // 有效emoji
	          richTextNode.push({
	            name: 'img',
	            attrs: {
	              width: '30rpx',
	              height: '30rpx',
	              src: emoji[emojiName].img
	            }
	          })
	        } else {//无效emoji
	          richTextNode.push({
	            type: 'text',
	            text: emojiName
	          })
	        }
	        tempStr = tempStr.substring(rightBracketIndex + 1, tempStr.length)
	      }
	    } else { // 开头不是[
	      if (leftBracketIndex == -1) {// 最后全是文字
	        richTextNode.push({
	          type: 'text',
	          text: tempStr.slice(0, tempStr.length)
	        })
	        tempStr = ''
	      } else {
	        richTextNode.push({
	          type: 'text',
	          text: tempStr.slice(0, leftBracketIndex)
	        })
	        tempStr = tempStr.substring(leftBracketIndex, tempStr.length + 1)
	      }
	    }
	  }
	  return richTextNode
	}
	/**
	 * 处理图片富文本节点
	 */
	generateImageNode(file) {
	  let width = 0, height = 0
	  if (file.w > 250) {
	    width = 200
	    height = file.h / (file.w / 200)
	  } else {
	    width = file.w
	    height = file.h
	  }
	  let richTextNode = []
	  richTextNode.push({
	    name: 'img',
	    attrs: {
	      width: `${width}rpx`,
	      height: `${height}rpx`,
	      src: file.url
	    }
	  })
	  return richTextNode
	}
	/**
	 * 输出猜拳图片对象，用于生成富文本图片节点
	 */
	 generateFingerGuessImageFile(value) {
	  let file = { w: 50, h: 50, url: '' }
	  switch (value) {
	    case 1:
	      file.url = 'http://yx-web.nos.netease.com/webdoc/h5/im/play-1.png'
	      break
	    case 2:
	      file.url = 'http://yx-web.nos.netease.com/webdoc/h5/im/play-2.png'
	      break
	    case 3:
	      file.url = 'http://yx-web.nos.netease.com/webdoc/h5/im/play-3.png'
	      break
	    default:
	      break
	  }
	  return file
	}
	/*环信判断数组中是否存在某个元素*/
	isExistGroup(name, list){
		for(let index = 0; index < list.length; index++){
			if(name == list[index].member || name == list[index].owner){
				return true
			}
		}
		return false
	}
	/*-----------------------------------------uni-app通用类函数--------------------------------------------------------*/
	/*uni-app的通用函数  (这个暂时不能用!!!)*/
	setData(obj) {
		let that = this;
		let keys = [];
		let val, data;
		Object.keys(obj).forEach(function(key) {
			keys = key.split('.');
			val = obj[key];
			data = that.$data;
			keys.forEach(function(key2, index) {
				if (index + 1 == keys.length) {
					that.$set(data, key2, val);
				} else {
					if (!data[key2]) {
						that.$set(data, key2, {});
					}
				}
				data = data[key2];
			})
		});
	}
}
export {
	GYZJMODEL
};
